<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>
<%@page import="java.util.Map"%>
<%@page import="com.feib.soeasy.util.CodeTableUtil"%>

<stripes:form name="queryDetailForm" 
	id="queryDetailForm" beanclass="com.feib.soeasy.action.Soez6001ActionBean"	method="post" onsubmit="javascript: return false;">	
<c:choose>
	<c:when test="${null != actionBean.queryResult && not empty actionBean.queryResult.paginatedList}">
	
	<div>
		<table id="listTable">
			<thead>						
				<tr>
					<th>No.</th>
						<c:choose>				
							<c:when test="${ actionBean.transfered eq 0  }">		
							<th>傳輸日期</th>
							</c:when>	
							<c:when test="${ actionBean.transfered eq 1  }">	
							<th>撥款日期</th>	
							</c:when>	
						</c:choose>
					
					
					<th>業者代號</th> 	
					<th>實體帳號</th>
					<th>業者名稱</th>
					<th>通路</th>
					<th>代收筆數</th>
					<th>入帳金額</th>	  
					<th>明細</th>	
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${actionBean.queryResult.paginatedList}" var="viewObj" varStatus="rowstat">
				
				<tr> 
					<td rowSpan='${fn:length(actionBean.queryChannels)+1}'  >${rowstat.index+1}</td>
					<td rowSpan='${fn:length(actionBean.queryChannels)+1}' align='center' >
						<c:choose>				
							<c:when test="${ actionBean.transfered eq 0  }">		
								<fmt:formatDate value="${actionBean.qryDateMin}" pattern="yyyy/MM/dd"   />
								<br>～<br>
								<fmt:formatDate value="${actionBean.qryDateMax}" pattern="yyyy/MM/dd"   />					
							</c:when>	
							<c:when test="${ actionBean.transfered eq 1  }">	
								<fmt:formatDate value="${viewObj.transferTime}" pattern="yyyy/MM/dd"   />						
								</c:when>	
						</c:choose>
					</td>
					<td rowSpan='${fn:length(actionBean.queryChannels)+1}' ><c:out value=" ${viewObj.groupNo }"/></td>
					<td rowSpan='${fn:length(actionBean.queryChannels)+1}' ><c:out value="${viewObj.accountNo}"/></td>
					<td rowSpan='${fn:length(actionBean.queryChannels)+1}' ><c:out value="${viewObj.groupName}"/></td>	
				</tr>
				<tr <c:if test="${  !fn:contains( actionBean.queryChannels, 'D' ) }">style='display:none;'</c:if> >
					
					
					<td align="right">統一</td>
					<c:choose>
						<c:when test="${viewObj.dCount==0}">
							<td align="center" colSpan="3"><c:out value="查無資料"/></td>
							
						</c:when>
						<c:otherwise>
							<td align="right"><c:out value="${viewObj.dCount}"/></td>
							<td align="right"><c:out value="${viewObj.dAmount}"/></td>	
							<c:choose>				
							<c:when test="${ actionBean.transfered eq 0  }">		
								<td>
									<div id='viewChannel-D<fmt:formatDate value="${actionBean.qryDateMin}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>	
							</c:when>	
								<c:when test="${ actionBean.transfered eq 1  }">	
								<td>
								<div id='viewChannel-D<fmt:formatDate value="${viewObj.transferTime}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>
								</c:when>
							</c:choose>	
							</c:otherwise>
					</c:choose>
					</tr>
				<tr 				
				<c:if test="${fn:indexOf(actionBean.queryChannels, 'E') % 2 == 0}"> bgcolor='#F4E3E3' </c:if> 		
				<c:if test="${!fn:contains( actionBean.queryChannels, 'E' ) }">style='display:none;'</c:if> 				
				>
					<td align="right">全家</td>
					<c:choose>
						<c:when test="${viewObj.eCount==0}">
							<td align="center" colSpan="3"><c:out value="查無資料"/></td>
							
						</c:when>
						<c:otherwise>
							<td align="right"><c:out value="${viewObj.eCount}"/></td>
							<td align="right"><c:out value="${viewObj.eAmount}"/></td>
							<c:choose>				
							<c:when test="${ actionBean.transfered eq 0  }">		
								<td>
									<div id='viewChannel-E<fmt:formatDate value="${actionBean.qryDateMin}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>	
							</c:when>	
								<c:when test="${ actionBean.transfered eq 1  }">	
								<td>
								<div id='viewChannel-E<fmt:formatDate value="${viewObj.transferTime}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>
								</c:when>
							</c:choose>	
						</c:otherwise>
					</c:choose>
						</tr>
				<tr 
				<c:if test="${fn:indexOf(actionBean.queryChannels, 'F') % 2 == 0}"> bgcolor='#F4E3E3' </c:if> 
				<c:if test="${  !fn:contains( actionBean.queryChannels, 'F' ) }">style='display:none;'</c:if> 
				>
					<td align="right"  >萊爾富</td>
					<c:choose>
						<c:when test="${viewObj.fCount==0}">
							<td align="center" colSpan="3"><c:out value="查無資料"/></td>
							
						</c:when>
						<c:otherwise>
							<td align="right"><c:out value="${viewObj.fCount}"/></td>
							<td align="right"><c:out value="${viewObj.fAmount}"/></td>
							<c:choose>				
							<c:when test="${ actionBean.transfered eq 0  }">		
								<td>
									<div id='viewChannel-F<fmt:formatDate value="${actionBean.qryDateMin}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>	
							</c:when>	
								<c:when test="${ actionBean.transfered eq 1  }">	
								<td>
								<div id='viewChannel-F<fmt:formatDate value="${viewObj.transferTime}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>
								</c:when>
							</c:choose>	
							</c:otherwise>
					</c:choose>
					</tr>
				<tr 
				<c:if test="${fn:indexOf(actionBean.queryChannels, 'G') % 2 == 0}"> bgcolor='#F4E3E3' </c:if> 
				<c:if test="${  !fn:contains( actionBean.queryChannels, 'G' ) }">style='display:none;'</c:if> 
				>
					<td align="right" >OK</td>
					<c:choose>
						<c:when test="${viewObj.gCount==0}">
							<td align="center" colSpan="3"><c:out value="查無資料"/></td>
							
						</c:when>
						<c:otherwise>
							<td align="right"><c:out value="${viewObj.gCount}"/></td>
							<td align="right"><c:out value="${viewObj.gAmount}"/></td>
							<c:choose>				
							<c:when test="${ actionBean.transfered eq 0  }">		
								<td>
									<div id='viewChannel-G<fmt:formatDate value="${actionBean.qryDateMin}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>	
							</c:when>	
								<c:when test="${ actionBean.transfered eq 1  }">	
								<td>
								<div id='viewChannel-G<fmt:formatDate value="${viewObj.transferTime}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>
								</c:when>
							</c:choose>	
							</c:otherwise>
					</c:choose>
					</tr>
				<tr  bgcolor='#F4E3E3' 
				<c:if test="${  !fn:contains( actionBean.queryChannels, 'H' ) }">style='display:none;'</c:if> 
				>
					<td align="right"  >郵局</td>
					<c:choose>
						<c:when test="${viewObj.hCount==0}">
							<td align="center" colSpan="3"><c:out value="查無資料"/></td>						
						</c:when>
						<c:otherwise>
							<td align="right"><c:out value="${viewObj.hCount}"/></td>
							<td align="right"><c:out value="${viewObj.hAmount}"/></td>
							<c:choose>				
							<c:when test="${ actionBean.transfered eq 0  }">		
								<td>
									<div id='viewChannel-H<fmt:formatDate value="${actionBean.qryDateMin}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>	
							</c:when>	
								<c:when test="${ actionBean.transfered eq 1  }">	
								<td>
								<div id='viewChannel-H<fmt:formatDate value="${viewObj.transferTime}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>
								</c:when>
							</c:choose>	
								</c:otherwise>
					</c:choose>
				</tr>
			
				<tr  >
				
					<td align="right" colSpan="6"><c:out value="統計"/></td>
						<td align="right"><c:out value="${viewObj.totalCount}"/></td>
						<td align="right"><c:out value="${viewObj.realAmount}"/></td>
						
						<c:choose>				
							<c:when test="${ actionBean.transfered eq 0  }">		
								<td>
								<div id='viewGroupAllChannel-<fmt:formatDate value="${actionBean.qryDateMin}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>	
							</c:when>	
								<c:when test="${ actionBean.transfered eq 1  }">	
								<td>
									<div id='viewGroupAllChannel-<fmt:formatDate value="${viewObj.transferTime}" pattern="yyyyMMdd"  /><c:out value="${viewObj.groupNo}"/>+<c:out value="${viewObj.accountNo}"/>'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>
								</c:when>
							</c:choose>	
						
						
						
					</tr>
				<c:if test = "${rowstat.last}" >
				<tr bgcolor="#F4E3E3" >
				 	<c:if test="${lastPageNumber<=currentPageNumber ? 'true': 'false'}">
					<td align="right" colSpan="4"><c:out value="總計"/></td>
					<td align="right" colSpan="2"><c:out value="超商/郵局合計"/></td>							
					<td align="right"><c:out value="${viewObj.allCount}"/></td>
					<td align="right"><fmt:formatNumber value="${viewObj.allAmount}" pattern="##,###" /></td>
				 	
				 	<c:choose>	
				 		<c:when test="${ actionBean.transfered eq 0  }">		
								<td>
								<div id='viewAllGroup-<fmt:formatDate value="${actionBean.qryDateMin}" pattern="yyyyMMdd"  />'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
								</td>	
							</c:when>	
								<c:when test="${ actionBean.transfered eq 1  }">	
								<td>
				 				<div id='viewAllGroup-<fmt:formatDate value="${viewObj.transferTime}" pattern="yyyyMMdd"  />'><a href="javascript: void(0)" class='btnZoom'>查詢</a></div>
				 				</td>
						</c:when>
					</c:choose>		
				 	</c:if>		
				</tr>
				</c:if> 
				</c:forEach>
			
				
			</tbody>
		</table>
		</div>
		<stripes:hidden id="hidden5.qryDateFrom" name="qryDateFrom"/>
		<stripes:hidden id="hidden5.qryDateTo" name="qryDateTo"/>
					
		<div id="paginationBar">
			<c:if test="${actionBean.transfered eq 0 }"> 
			<input type="button" id="doTransfer" value="確認撥款" onclick="javascript:divPrint('queryCommissionCodeResultDiv');"/> 
			</c:if> 
			
			<input type="button" id="doDownloadExcelFileBtn" name="doDownloadExcelFileBtn"  value="下載(Excel)" onclick="javascript:doDownloadExcelFileAction();" />
			<input type="button" id="printBtn2" value="列印" onclick="javascript:divPrint('queryCommissionCodeResultDiv');"/>
			<c:if test="${actionBean.transfered eq 1 }"> 
			<input type="button" id="doDownloadFile" value="下載媒體檔" onclick="javascript:divPrint('queryCommissionCodeResultDiv');"/>
			 </c:if> 
			
		</div>
		
		
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
			$( "#queryNothingBlockDiv" ).dialog({  title:'<%=UserUtil.getCurrentMenuItemName() %>' ,width: 300, resizable: false, modal: true, buttons : {
				Ok : function() {
					$(this).dialog("close");
				}
			}  
			});

			
			$("[id^='viewChannel-']").click(function() {
				var uid = this.id.substring(12);
				doQueryChannelAction(uid);
			});
			
			$("[id^='viewGroupAllChannel-']").click(function() {
				var uid = this.id.substring(20);
				doQueryGroupAllChannelAction(uid);
			});
			
			$("[id^='viewAllGroup-']").click(function() {
				var uid = this.id.substring(13);
				doQueryAllGroupAction(uid);
			});
			
		});
		//-->
		</script>	
	
		

	</c:when>
	<c:otherwise>
	
	
		
	<table id="listTable">
			<thead>						
				<tr>
					<th>NO.</th>
					<th>撥款日期</th>
					<th>業者代號</th> 	
					<th>實體帳號</th>
					<th>業者名稱</th>
					<th>通路</th>
					<th>代收筆數</th>
					<th>實撥金額</th>	    
			</tr>
			</thead>
		</table>	
		
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
			$( "#queryNothingBlockDiv" ).dialog({  title:'<%=UserUtil.getCurrentMenuItemName() %>' ,width: 300, resizable: false, modal: true, buttons : {
				Ok : function() {
					$(this).dialog("close");
				}
			}  
			});

		
		});
		//-->
		</script>			
	</c:otherwise>
</c:choose>
</stripes:form>